package day240802.e4;

import java.util.ArrayList;
import java.util.List;

public class TicketWindows {
    static final List<String> tickets = new ArrayList<>();

    static{
        for(int i = 1; i <= 10000; i++){
            tickets.add("车票编码-" + i);
        }
    }

    public static void main(String[] args) {
        for(int i = 0; i < 10; i++){
            new Thread(() ->  {
                    while(true){
                        synchronized (tickets) {
                            if(!tickets.isEmpty()){
                                System.out.println(Thread.currentThread().getName() + " 售出---" + tickets.remove(0) + ",剩余票数：" + tickets.size());
                            }else{
                                break;
                            }
                        }
                    }
            }).start();
        }
    }
}
